package com.example.demo;

import org.geotools.api.feature.Property;
import org.geotools.api.feature.simple.SimpleFeature;
import org.locationtech.jts.geom.Geometry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Iterator;

public class AnalysisUtil {

    private static final Logger logger = LoggerFactory.getLogger(AnalysisUtil.class);

    public static void readProperty(SimpleFeature simpleFeature) {
        Collection<Property> properties = simpleFeature.getProperties();
        Iterator<Property> iterator = properties.iterator();
        int index = 0;
        while (iterator.hasNext()) {
            Property property = iterator.next();
            //kml拿到属性值会有自带的9个属性
            if (index++ > 8) {
                logger.info("GeoJSONReader解析geojson -->> 属性名：【{}】，属性值：【{}】，属性类型：【{}】", property.getName().toString(),
                        property.getValue(), property.getType().getBinding());
            }
        }
        Object defaultGeometry = simpleFeature.getDefaultGeometry();
        //wkt格式geometry
        Geometry geometry = (Geometry) defaultGeometry;
        logger.info("wkt格式geometry：{}", geometry);
    }
}
